package scantask.client.threeDObjects;

import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.layers.AirspaceLayer;
import gov.nasa.worldwind.render.airspaces.CappedCylinder;

import java.awt.Color;

import scantask.client.presentationLayer.FunctionalityPanel;
import scantask.client.presentationLayer.Presentation;
import scantask.client.threeDObjects.exceptions.Illegal3DObjectParameter;
import scantask.containers.PestsLevelsSigelton;

public class Cylinder extends LeafPolygone {
	
	private int _radius;

	public Cylinder(Color color, double xCenter, double yCenter, double buttom,
			double up, int angle, int radius, double value) throws Illegal3DObjectParameter {
		super(color, xCenter, yCenter, buttom, up, angle, value);
		
		if (radius <= 0) {
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Fail illegal radius entered");
			throw new Illegal3DObjectParameter();
		}
		
		this._radius = radius;
		
		
	}

	@Override
	public ComponentPolygone clone() {
		ComponentPolygone ans = null;
		try {
			ans = new Cylinder(this._color, this._xCenter, this._yCenter,
					this._buttom, this._up, this._angle, this._radius, this._value);
		} catch (Illegal3DObjectParameter e) {
			// AdirD - Impossible exception
		}
		
		return ans;
	}
	
	@Override
	public void init3DObject(AirspaceLayer layer){
		super.init3DObject(layer);
		this._shape3D = new gov.nasa.worldwind.render.airspaces.CappedCylinder();
		((CappedCylinder)this._shape3D).setCenter(
				LatLon.fromDegrees(this._yCenter, this._xCenter));
		((CappedCylinder)this._shape3D).setRadius(this._radius);
		this._shape3D.setAltitudes(this._buttom, this._up + Math.abs(this._up - this._buttom)* FunctionalityPanel.DEFAULT_FACTOR);
		Presentation.AppFrame.setAttr(this._shape3D, this._color, Color.ORANGE);
//		this.setDescription("Measurement value is: " + 
//						PestsLevelsSigelton.getPestLevel(this._value));
	}

}
